package reader;

// 读者类
class Reader {
    int readerID;        // 读者编号
    String readerName;   // 读者姓名
    String readerPwd;    // 读者密码
    double balance;      // 账户余额
    String note = "\n读者类操作结果提示:";  // 操作提示
    private static int nextReaderID = 10001;  // 读者起始编号

    public Reader() {  // 无参构造方法
        readerID = nextReaderID++;
        readerName = "";
        readerPwd = "666666";
        balance = 0;
    }

    public Reader(String name) {  // 带姓名参数的构造方法
        this();
        readerName = name;
    }

    public int getReaderID() {
        return readerID;
    }

    public void setReaderName(String newname) {
        readerName = newname;
    }

    public String getReaderName() {
        return readerName;
    }

    public void setReaderPwd(String newpwd) {
        if (newpwd.length() < 6) {
            note = "提醒:密码长度不要小于6位，太短不安全哦!";
        } else {
            readerPwd = newpwd;
            note = "\n修改密码成功!";
        }
    }

    public String getReaderPwd() {
        return readerPwd;
    }

    public void setBalance(double moreMoney) {  // 账户充值
        if (moreMoney < 0) {
            note = "充值不能为负数!";
        } else {
            balance = balance + moreMoney;
            note = "\n充值成功!";
        }
    }

    public double getBalance() {
        return balance;
    }

    public String toString() {
        return "读者编号:" + readerID + " 姓名:" + readerName + " 密码:" + readerPwd +
                " 账户余额:" + balance;
    }
}
